<?php session_start();
    class LoginController extends dl_connect{
        
        function __construct(){
            $this->Connect();
        }
        
        function checkLogin(){
            if(isset($_POST['txtname']) && isset($_POST['txtpass'])){
                $name=$_POST['txtname'];
                $pass=md5($_POST['txtpass']);
                $result = $this->ExecuteSQL("select * from user where name='".$name."' and pass ='".$pass."' ")or die("connection error");
                if(mysql_num_rows($result)>0){ 
                    $_SESSION['name']=$name;
                    echo '<script language="javascript">
                                alert("Đăng nhập thành công");
                                document.location="index.php?rt=admin";
                          </script>';
               }else{
                    echo '	<script language="javascript">
                            alert("Đăng nhập bị lỗi, vui lòng thử lại");
                            document.location="index.php";
                            </script>';
               }
            
            }
        }
    }
    
    $login = new LoginController();
    $login->checkLogin();
?>
